package cn.kgc83.shengyin.service.impl;

import java.util.Collections;
import java.util.List;

import cn.kgc83.shengyin.service.ISurveyService;
import cn.kgc83.shengyin.vo.SurveyQues2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.kgc83.shengyin.domain.*;
import cn.kgc83.shengyin.mapper.*;
/**
 * 调查问卷Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-08-01
 */
@Service
public class SurveyServiceImpl implements ISurveyService
{
    @Autowired
    private SurveyMapper surveyMapper;

    /**
     * 查询调查问卷
     * 
     * @param id 调查问卷主键
     * @return 调查问卷
     */
    @Override
    public Survey selectSurveyById(Long id)
    {
        return surveyMapper.selectSurveyById(id);
    }

    /**
     * 查询调查问卷列表
     * 
     * @param survey 调查问卷
     * @return 调查问卷
     */
    @Override
    public List<Survey> selectSurveyList(Survey survey)
    {
        return surveyMapper.selectSurveyList(survey);
    }

    /**
     * 新增调查问卷
     * 
     * @param survey 调查问卷
     * @return 结果
     */
    @Override
    public int insertSurvey(Survey survey)
    {
        return surveyMapper.insertSurvey(survey);
    }

    /**
     * 修改调查问卷
     * 
     * @param survey 调查问卷
     * @return 结果
     */
    @Override
    public int updateSurvey(Survey survey)
    {
        return surveyMapper.updateSurvey(survey);
    }

    /**
     * 批量删除调查问卷
     * 
     * @param ids 需要删除的调查问卷主键
     * @return 结果
     */
    @Override
    public int deleteSurveyByIds(Long[] ids)
    {
        return surveyMapper.deleteSurveyByIds(ids);
    }

    /**
     * 删除调查问卷信息
     * 
     * @param id 调查问卷主键
     * @return 结果
     */
    @Override
    public int deleteSurveyById(Long id)
    {
        return surveyMapper.deleteSurveyById(id);
    }

    @Override
    public  List<Long> generate(Long stype,int size){
        List<Long> ques = this.surveyMapper.findQues(stype);
        Collections.shuffle(ques);
        Collections.shuffle(ques);
        Collections.shuffle(ques);
        //System.out.println(ques.size()+",,,,,,,"+size);
        List<Long> id2 = ques.subList(0, size);
        return id2;
    }
    public  List<SurveyQues2> findSurvQueses(long[] r){
        return this.surveyMapper.findSurveyByIds(r);
    }
}
